
package com.tg.demo.entity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 权限枚举
 *
 * @author yj
 */
public enum AuthEnum {

    /**
     * 超级管理员
     */
    WOMAN(1, "超级管理员"),

    /**
     * 管理员
     */
    MAN(2, "管理员");

    private int key;
    private String value;

    private AuthEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public static AuthEnum getEnumByKey(int key) {
        for (AuthEnum c : AuthEnum.values()) {
            if (key == c.getKey()) {
                return c;
            }
        }
        return null;
    }

    public static AuthEnum getEnumByVal(String val) {
        for (AuthEnum c : AuthEnum.values()) {
            if (val.equals(c.getValue())) {
                return c;
            }
        }
        return null;
    }

    public static List<AuthEnum> getListEnum() {
        return new ArrayList<AuthEnum>(Arrays.asList(AuthEnum.values()));
    }

    public static List<Integer> getListKeyEnum() {
        List<Integer> enumListKey = new ArrayList<Integer>();
        for (AuthEnum c : AuthEnum.values()) {
            enumListKey.add(c.getKey());
        }
        return enumListKey;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
